#ifndef SERVER_H
#define SERVER_H

#include<iostream>
#include<mutex>
#include<cstring>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <thread>
#include<set>
const int BUF_SIZE = 100;
class server{
    private:
        unsigned short port;//端口号
        int server_sock;//设为listen状态的套接字描述符
        unsigned long ip;//服务器ip
        std::set<int> sock_clns;//保存所有套接字描述符
        std::mutex m;
    public:
        server(unsigned short p):port(p),ip(INADDR_ANY){};//构造函数
        server(unsigned short p,std::string i);
        void start();
        void run();
        ~server();
        void error(std::string m){std::cerr<<m<<" "<<errno<<std::endl;exit(-1);}
        void handle(int);
};

#endif